#pragma once

#include "d3dApp.h"
#include <tchar.h>
#include <crtdbg.h>
//#include <list>
#include "GfxStats.h"
#include "DInput.h"
#include "reader.h"
#include <time.h>
//#include "Tiles.h"
//#include "Branch.h"

#include "DirectSound.h"
#include "dsound.h"
#include "Ai-Kun.h"

class MazeWars : public D3DApp
{

public:
	MazeWars(HINSTANCE hInstance, std::string winCaption, D3DDEVTYPE devType, DWORD requestedVP);
	~MazeWars();

	/********************Needed for any program you instantiate***************************/
	bool checkDeviceCaps();
	void onLostDevice();
	void onResetDevice();
	void updateScene(float dt);
	void drawScene();
	/*************************************************************************************/

	/**************Specific to application*************************************************/
	void drawMenu();
	void drawTile();
	RECT updateTile();
	void drawCursor();
	void updateMenu(float dt);
	void setRank1Pos();
	void updateCursor(float dt, int playerNum);
	void createTrunk();
	void createSpellTree(fileReader *reader, int nodeNbr, SpellType spell, int player);
	void drawBranches();
	//void drawGameCursor(int);
	//added 10/21/07
	void setCoolDown(int nodeID, int rank, int player);
	/*************************************************************************************/

	// Zach tests windows drawing stuffs
	void drawTile(int player);
	void drawBranches(int player);
	void drawGameCursor(int player);

	// Zachs testing of collness

	void updateBar();
	void drawLifeBar(Player *p, float x, float y);
	void drawPlayer(Player *p);

	// added 11/01/07

	// This will set up the spell anime, for each a player and play the coorasponding spell animation and the only spell animation is fireball....
	void playanime(int player, int spellNum);

	void drawAnime();
	void updateAnime(float);
	int getPlayer1Health();





private:

	float portraitPosX[NUMPLAYERS];

	GfxStats* mGfxStats;

	//the one and only sprite interface through which we do all of our sprite drawing
	ID3DXSprite* mSprite;

	//game cursor bmp
	IDirect3DTexture9* gameCursor;
	D3DXVECTOR3 gameCursorCenter;
	D3DXVECTOR3 gameCursorPosition;
	int currFrame;
	int spellCurrFrame;
	bool spellFinalFrames;

	D3DXVECTOR3 mLifeBarPos;

	D3DXVECTOR3 gameCursorCenter2;
	D3DXVECTOR3 gameCursorPosition2;
	//background properties
	IDirect3DTexture9* mBkgdTex;
	D3DXVECTOR3 mBkgdCenter;

	//cursor properties
	IDirect3DTexture9* mMenuCursor;
	D3DXVECTOR3 mMnuCurCenter;
	D3DXVECTOR3 mMnuCurPos;

	int CURSOR_POSITION;

	//tile info
	IDirect3DTexture9* mTile;

	int getNext();
	void MazeWars::initIt();

	//backbuffer info: needed for viewports


	
	// adds in the sound class
	CDirectSound sound;

	// Adds in the player and AI
	Player* player[NUMPLAYERS];
	
	AI* ai;

	

	//added 10/21/07
	IDirect3DTexture9* mCoolDownPallet;

	// add 10/22/07

	IDirect3DTexture9* Battle;

	// added 11/01/07
	

	float DXA, DYA; // The speed the anime is going to  change at.

	bool anime;

	//added 11/26/07
	float halfTileWidth;
	float tileWidth;

//	float dx;
//	float dy;
	
	float dxp2;
	float dyp2;

	// added 01/28/08 - Multi - Zach
	//Player* player2;


};